import {createRouter, createWebHashHistory,createWebHistory} from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SearchView from '@/views/SearchView.vue'

import NotFound from '@/views/NotFound.vue'
import MyView from '@/views/MyView.vue'
const routes = [
  // {path: '/home', component: HomeView},
  // {path: '/search', component: SearchView}

  // 重定向
  // path 解析到的地址 跳转到 redirect 对应的地址
  {path:'/',redirect:'/home'},
  // 动态路由传递参数
  {path: '/home', component: HomeView},
  {path: '/search/:words?', component: SearchView},
  {path: '/my', component: MyView},

  // 404 页面(找不到时候触发)
  {path:'/:pathMatch(.*)*',name:'NotFound',component:NotFound}
]

const router = createRouter({
  // hash模式  url中有 #
  // history: createWebHashHistory(),
  // history模式 没有# url更为精美 (比较常用德模式)
   history: createWebHistory(),
  routes
})

export default router
